//
// Created by fanghr on 17-12-30.
//

#include "rw_lock.h"

rw_lock::rw_lock() {
    pthread_rwlock_init(&this->m_Mutex, NULL);
}

rw_lock::~rw_lock() {
    pthread_rwlock_destroy(&this->m_Mutex);
}

void rw_lock::lock() {
    pthread_rwlock_wrlock(&this->m_Mutex);
}

void rw_lock::unlock() {
    pthread_rwlock_unlock(&this->m_Mutex);
}

void rw_lock::lock_shared() {
    pthread_rwlock_rdlock(&this->m_Mutex);
}

void rw_lock::unlock_shared() {
    pthread_rwlock_unlock(&this->m_Mutex);
}
